import { request } from 'umi';

export async function fakeSubmitForm(params: any) {
  return request('/api/cmsArticle/save', {
    method: 'POST',
    data: params,
  });
}

export async function queryArticleDetail(params: any) {
  return request('/api/cmsArticle/' + params.id, {
    method: 'get',
    data: params,
  });
}


export async function updateTop(params: any) {
  return request('/api/cmsArticle/isTop', {
    method: 'POST',
    data: params,
  });
}


export async function updateShareAndView(
  params: ParamsType,
): Promise<{ data: { list: BasicListItemDataType[] } }> {
  return request('/api/cmsArticle/updateAccessData', {
    method: 'POST',
    data: params,
  });
}

export async function list(params: any) {
  return request('/api/cmsArticle/page', {
    method: 'POST',
    data: params,
  });
}

/** 修改文章 PUT /api/Article */
export async function updateArticle(params: any) {
  return request('/api/cmsArticle/edit', {
    method: 'PUT',
    data: params,
  });
}

/** 删除文章 DELETE /api/Article */
export async function removeArticle(data: { key: number[] }, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/cmsArticle/' + data.key, {
    data,
    method: 'DELETE',
    ...(options || {}),
  });
}
